<!DOCTYPE html>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>位置服务</title>
    <!--<script type="text/javascript" src="/resources/pangdahai/js/baiduMap1.3.js"></script>-->
    <!--<link rel="stylesheet" type="text/css" href="/resources/pangdahai/css/baiduMap1.3.css"/>-->
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>

</head>
<body>
<div style="width:900px;height:500px;border:1px solid gray;" id="container">
</div>
</body>
</html>
<script type="text/javascript">
    var map = new BMap.Map("container");
    //    var point1 = new BMap.Point(104.067923,30.679943);
    //    var point = new BMap.Point(116.356443, 39.813621);
    map.enableScrollWheelZoom();
    map.addControl(new BMap.NavigationControl());
    map.addControl(new BMap.ScaleControl());
    map.addControl(new BMap.OverviewMapControl());
    var myGeo = new BMap.Geocoder();
    var pointList = [new BMap.Point(116.356443, 39.813621), new BMap.Point(116.306443, 39.803621)];
    for (var i = 0; i < pointList.length; i++) {
        var point = pointList[i];
        var marker = new BMap.Marker(point);
        map.centerAndZoom(point, 11);
        map.addOverlay(marker);
        myGeo.getLocation(point, function (result) {
            if (result.address) {
                var opts = {
//        width : 50,     // 信息窗口宽度
//        height: 20,     // 信息窗口高度
                    title:result.address  // 信息窗口标题
                }
                var infoWindow = new BMap.InfoWindow("", opts);  // 创建信息窗口对象
                map.openInfoWindow(infoWindow, point);      // 打开信息窗口
                marker.addEventListener("click", function () {
                    map.openInfoWindow(infoWindow, point);
                });
            } else {
                var infoWindow = new BMap.InfoWindow("无法定位", '');  // 创建信息窗口对象
                map.openInfoWindow(infoWindow, point);      // 打开信息窗口
            }
        });

    }
    /*map.centerAndZoom(point, 12);
     map.enableScrollWheelZoom();
     map.addControl(new BMap.NavigationControl());
     map.addControl(new BMap.ScaleControl());
     map.addControl(new BMap.OverviewMapControl());
     var myGeo = new BMap.Geocoder();
     var marker = new BMap.Marker(point);
     map.addOverlay(marker);
     myGeo.getLocation(point, function(result){
     if(result.address){
     var opts = {
     //        width : 50,     // 信息窗口宽度
     //        height: 20,     // 信息窗口高度
     title : result.address  // 信息窗口标题
     }
     var infoWindow = new BMap.InfoWindow("", opts);  // 创建信息窗口对象
     map.openInfoWindow(infoWindow, point);      // 打开信息窗口
     marker.addEventListener("click", function(){
     map.openInfoWindow(infoWindow, point);
     });
     } else {
     var infoWindow = new BMap.InfoWindow("无法定位", '');  // 创建信息窗口对象
     map.openInfoWindow(infoWindow, pointList);      // 打开信息窗口
     }
     });*/

    //addMarker(new BMap.Point(116.404, 39.915), 0);//添加标记


</script>
